import mongoose = require('mongoose');
import WebConstant from "./WebConstant";

export default class MongoDBConn{

  private dataMongoBase:string = WebConstant.dbConn;
  public connectDB(onOpen:any, onError:any):void{
    let me = this;
    let promise = mongoose.connect(me.dataMongoBase,{ useNewUrlParser: true });

    promise.then(()=>{
      onOpen();
    },(err:any) => {
      onError();
    });

    promise.catch((err:any)=>{
      onError();
    });
  }

}